// import request from '/utils/request'
import {
  request
} from "./request.js";

//  登陆-注册
export function login(data) {
  return request(
    "/User/AutoLogin",
    "post",
    data
  );
}

// 检查是否已注册
export function checkRegister(data) {
  return request(
    "/User/Exist",
    "post",
    data
  );
}

// 查询全部字典
export function getDictTree(data) {
  return request(
    "/api/PubSysDic/dictree",
    "get",
    data
  );
}

// 首页banner配置项
export function getConfigOptions(data) {
  return request(
    "/api/Index/EntryList",
    "get",
    data
  );
}


// 区划
export function getAreaListByCode(code,isCustomLoading) {
  return request(
    `/api/SysArea/${code}/tree`,
    "get",
    {},
    isCustomLoading
  );
}


// 地址列表
export function getMyAddressList(data) {
  return request(
    "/api/Address",
    "get",
    data
  );
}

// 获取用户信息
export function getUser(params) {
  return request(
    "/api/User/Info",
    "get",
    params
  );
}


// 地址新增
export function saveMyAddress(data) {
  return request(
    "/api/Address",
    "post",
    data
  );
}

// 地址编辑
export function editMyAddress(id,data) {
  return request(
    `/api/Address/${id}`,
    "put",
    data
  );
}

// 地址详情
export function getAddressInfo(data) {
  return request(
    `/api/Address/${data}`,
    "get"
  );
}

// 删除我的地址
export function delMyAddress(id) {
  return request(
    `/api/Address/${id}`,
    "delete"
  );
}


// 服务预约提交
export function submitServoceOrder(data) {
  return request(
    "/api/ServiceOrder",
    "post",
    data
  );
}

// 服务订单列表
export function getServiceOrder(params,isCustomLoading) {
  return request(
    "/api/ServiceOrder",
    "get",
    params,
    isCustomLoading
  );
}

// 商品订单列表
export function getGoodsOrder(params,isCustomLoading) {
  return request(
    "/api/ProductOrder",
    "get",
    params,
    isCustomLoading
  );
}

// 确认收货
export function sureReceive(id,params) {
  return request(
    `/api/ProductOrder/${id}/FinishOrder`,
    "put",
    params
  );
}

// 取消订单
export function cancelMyOrder(id,params) {
  return request(
    `/api/ServiceOrder/${id}/Cancle`,
    "put",
    params
  );
}

// 服务订单详情
export function getServiceOrderDetail(id) {
  return request(
    `/api/ServiceOrder/${id}`,
    "get"
  );
}

// 商品订单详情
export function getGoodsOrderDetail(id) {
  return request(
    `/api/ProductOrder/${id}`,
    "get"
  );
}

// 修改用户信息
export function editUserInfo(params) {
  return request(
    `/api/User/Info`,
    "put",
    params
  );
}

// 获取购物车列表
export function getShopCarList(params) {
  return request(
    `/api/ProductGoodsShoppingCart`,
    "get",
    params
  );
}

// 删除购物车商品
export function delShopCar(params) {
  return request(
    `/api/ProductGoodsShoppingCart/BatchDelete`,
    "delete",
    params
  );
}

// 创建商品订单评价
export function createGoodsEvaluate(id,data) {
  return request(
    `/api/ProductOrder/${id}/Evaluate`,
    "put",
    data
  );
}

// 创建服务订单评价
export function createServerEvaluate(id,data) {
  return request(
    `/api/ServiceOrder/${id}/Evaluate`,
    "put",
    data
  );
}